<template>
  <div class="avue-sidebar">
    <el-scrollbar style="height:100%">
      <!-- <div v-if="!menu" class="avue-sidebar--tip">没有发现菜单</div> -->
      <el-menu v-if="menu" id="my-menu" :default-active="nowTagValue" :show-timeout="200" :collapse="keyCollapse"
        unique-opened mode="vertical">
        <sidebar-item :menu="menu" :screen="screen" :props="website.menu.props" :collapse="keyCollapse" first
          popper-class="sidebar-popper-class" />
      </el-menu>
      <div class="menu-func" v-if="showCollapse" :class="[{ 'avue-breadcrumb': isCollapse }]">
        <img v-if="isCollapse" class="icon-menu" src="../../../../public/images/icon_menu_retract.png" alt=""
          @click="setCollapse">
        <img v-else class="icon-menu icon-menu-avue-breadcrumb" src="../../../../public/images/icon_menu_open.png" alt=""
          @click="setCollapse">
        <span v-show="!isCollapse">收起导航</span>
      </div>
    </el-scrollbar>
  </div>
</template>

<script>
import { mapGetters, mapState } from 'vuex'
import sidebarItem from './sidebarItem'
export default {
  name: 'Sidebar',
  inject: ['Index'],
  components: { sidebarItem },
  computed: {
    ...mapState({
      showCollapse: state => state.common.showCollapse
    }),
    ...mapGetters(['website', 'menu', 'tag', 'keyCollapse', 'screen', 'isCollapse']),
    nowTagValue: function () {
      return this.$router.$avueRouter.getValue(this.$route)
    }
  },
  created() {
    this.Index.openMenu(this.menuId)
  },
  methods: {
    setCollapse() {
      this.$store.commit('SET_COLLAPSE')
    }
  }
}
</script>
<style lang="scss" scoped>
.menu-func {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 216px;
  height: 36px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #fff;
  border-top: 1px solid #DEDEDE;
  font-weight: 400;
  color: #6D7075;
  font-size: 12px;

  .icon-menu {
    width: 18px;
    height: 18px;
  }

  .icon-menu-avue-breadcrumb {
    margin-right: 10px;
  }
}

.avue-breadcrumb {
  width: 60px;
}

::v-deep .el-scrollbar__wrap {
  margin-right: 0 !important;
  overflow: auto;
  height: calc(100% - 37px);
}
</style>



